<?php
namespace admin\model;
use framework\core\Model;
class TopicModel extends Model{
    protected $login_table='ask_topic';
    //测试标题和描述是否合法
    public function checkData($data){
        if ($data['topic_title']==''){
            $this->error[]='话题的标题不能为空';
        }else if($data['topic_desc']==''){
            $this->error[]='话题的描述不能为空';
        }
        if (empty($this->error)){
            //数组为空代表没有错误信息
            return true;
        }else{
            return false;
        }
    }
    //查询topic表中的所有数据
    public function getAllTopics(){
        $sql="select * from $this->true_table";
        return $this->dao->fetchAll($sql);
    }
    //根据topic_id查询出满足条件的一条信息
    public function getInfoByid($topic_id){
        $sql="select * from $this->true_table where topic_id=$topic_id";
        return $this->dao->fetchRow($sql);
    }
}